package top.licoba.testsdk;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import top.licoba.configsdk.ConfigUtil;
import top.licoba.configsdk.OnStateChangeListener;

public class MainActivity extends AppCompatActivity {

    ConfigUtil configUtil;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn_blu = findViewById(R.id.button_blu);
        Button btn_blu_cancel = findViewById(R.id.button_blu_cancel);
        btn_blu.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                configUtil = ConfigUtil.init(MainActivity.this)
                        .wifiName("CMCC-EDU")
                        .wifiPwd("test123123")
                        .macContainSting("61EC")
                        .startBluConfig();

                configUtil.setOnStateChangeListener(new OnStateChangeListener() {

                    @Override
                    public void onConfig(int code) {
                        Log.e("SDK","onConfig:"+code);
                    }

                    @Override
                    public void onSuccess() {
                        Log.e("SDK","onSuccess");
                    }

                    @Override
                    public void onError(int code) {
                        Log.e("SDK","onError:"+code);
                    }
                });

            }
        });


        btn_blu_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(configUtil!=null){
                    configUtil.cancelConfig();
                }
            }
        });




    }
}
